package com.sengled.cloud.biz.union.mgt.model.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by FMC on 2017/11/4.
 */
public enum AccountStatusEnum {
    //账户状态: 1 在线、2 离线、3 锁定、4 失效
    ACCOUNT_STATUS_ONLINE(1, "在线"),
    ACCOUNT_STATUS_OFFLINE(2, "离线"),
    ACCOUNT_STATUS_LOCKED(3, "锁定"),
    ACCOUNT_STATUS_INVALID(4, "失效");

    public static Map<Integer, String> enumMap = new HashMap();

    static {
        AccountStatusEnum[] items = AccountStatusEnum.values();
        for (AccountStatusEnum item : items) {
            enumMap.put(item.getKey(), item.getValue());
        }
    }

    public static Integer getKeyByValue(String value) {
        AccountStatusEnum[] channels = AccountStatusEnum.values();
        for (AccountStatusEnum channel : channels) {
            if (channel.getValue().equalsIgnoreCase(value)) {
                return channel.getKey();
            }
        }
        return null;
    }

    public static String getValueByKey(Integer key) {
        AccountStatusEnum[] channels = AccountStatusEnum.values();
        for (AccountStatusEnum channel : channels) {
            if (channel.getKey() == key) {
                return channel.getValue();
            }
        }
        return null;
    }

    private AccountStatusEnum(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    private Integer key;
    private String value;

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
